package com.bi.design.pojo;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.bi.design.consts.TimeConsts;
import org.springframework.format.annotation.DateTimeFormat;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Objects;


public class TimeRangePageQuery extends BasePage {
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date startTime;

    @DateTimeFormat(pattern = "yyyy-MM-dd")
    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
    private Date endTime;

    public String getStartTime() {
        if (Objects.nonNull(startTime)) {
            return new SimpleDateFormat(TimeConsts.DATE_FORMATTER_DATE).format(startTime)+" 00:00:00";
        }
        return null;
    }

    public void setStartTime(Date startTime) {
        this.startTime = startTime;
    }

    public String getEndTime() {
        if (Objects.nonNull(endTime)) {
            return new SimpleDateFormat(TimeConsts.DATE_FORMATTER_DATE).format(endTime) + " 23:59:59";
        }
        return null;
    }

    public void setEndTime(Date endTime) {
        this.endTime = endTime;
    }

    @Override
    public String toString() {
        return super.toString() + "TimeRangePageQuery{" +
                "startTime=" + startTime +
                ", endTime=" + endTime +
                '}';
    }
}
